package com.aji.wineserver.mapper;

import com.aji.winepojo.dto.WineDto;
import com.aji.winepojo.entity.ClassData;
import com.aji.winepojo.entity.IdentData;
import com.aji.winepojo.entity.Wine;
import com.aji.winepojo.entity.WineAdd;
import com.aji.winepojo.vo.WineVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface WineMapper extends BaseMapper<Wine> {
    List<WineVo> pageQuery(WineDto wineDto);

    WineVo selectById(int id);

    void deleteByIds(List<Integer> ids);


    void add(List<WineAdd> wineAdds);

    void upDate(Wine wine);

    @Select("select class_name,count(*) as number\n" +
            "from wine\n" +
            "left join class on wine.wine_class = class.class_id\n" +
            "GROUP BY class_name")
    List<ClassData> selectClassData();

    @Select("select iden_status,count(*) as number\n" +
            "from wine\n" +
            "left join identification on wine.wine_ident = iden_id\n" +
            "GROUP BY iden_status")
    List<IdentData> selectIdentData();

    List<WineVo> listByIds(List<Integer> ids);

    void changeIdentfication(List<Integer> ids);

    WineVo selectOne(String wineName);
}
